package com.ganmiao.server.supplier.mapper;

import com.ganmiao.server.supplier.entity.Product;
import com.ganmiao.server.supplier.entity.Supplier;
import com.ganmiao.server.supplier.entity.Tender;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Select("<script>" +
            "select * from product " +
            "<if test='id != null' >" +
            "where id = #{id}" +
            "</if>" +
            "</script>")
    public Product productGet(Integer id);

    @Select("select * from tenders")
    public List<Product> getAllProducts();

    @Insert("insert into product(id, name, details)" +
            "values(#{id},#{name},#{details})")
    public Integer productCreate(Product product);

    @Delete("DELETE FROM product WHERE id = #{id}")
    public void productDelete(Integer id);

    @Update("UPDATE product SET id = #{id}, name = #{name}, details = #{details} WHERE id = #{id}")
    public void productUpdate(Integer id, String name, String details);
}
